package VN.EDU.IMIC.DEVELOPER.TRINHCAOSANG.ExceptionHandling;

public class Uncheck_TryCatch {
    public static void main(String[] args) {
     /*      int a=50/0;//ArithmeticException
        String b=null;
        System.out.println(b.length());//NullPointerException
        String c="abc";
        int i=Integer.parseInt(c);//NumberFormatException
        int d[]=new int[9];
        d[10]=50; //ArrayIndexOutOfBoundsException
    */
      /* Try catch
        int data1=50/0;//co the tao ra exception
        System.out.println("Phan code con lai...");

        try {
            int data2=50/0;//co the tao ra exception
        } catch (ArithmeticException e) {
            e.printStackTrace();
        }
        System.out.println(" other code...");
        //
        */
        /*
        try{
            int a[]=new int[5];
            a[5]=30/0;
        }
        catch(ArithmeticException e){System.out.println("Task1 duoc hoan thanh");}
        catch(ArrayIndexOutOfBoundsException e){System.out.println("Task2 duoc hoan thanh");}
        catch(Exception e){System.out.println("Task chung duoc hoan thanh");}

        System.out.println("other code...");
        //Arithemic chay truoc Expception . Nguoc lai se compile error
        */
        /* Nested try catch
        try{
            try{
                System.out.println("Thuc hien phep chia");
                int b =39/0;
            }catch(ArithmeticException e){System.out.println(e);}

            try{
                int a[]=new int[5];
                a[5]=4;
            }catch(ArrayIndexOutOfBoundsException e){System.out.println(e);}

            System.out.println("Lenh khac");
        }catch(Exception e){System.out.println("Da xu ly");}

        System.out.println("Luong chuan..");
        */
    }

}
